package metamodel;

public class Attribute implements Accessorizable {

	private String name;
	
	private String type;
	
	private String accessor;
	
	private boolean isCollection;

	public Attribute(String name, String type, String accessor, boolean isCollection) {
		this.name = name;
		this.type = type;
		this.accessor = accessor;
		this.isCollection = isCollection;
	}
	
	public Attribute(String name, String type, String accessor) {
		this(name, type, accessor, false);
	}
	
	public Attribute(String name, String type) {
		this(name, type, "");
	}

	public String getName() {
		return this.name;
	}

	public String getType() {
		if (isCollection) {
			return "Set<" + type + ">";
		}
		return type;
	}


	public void setAccessor(String accessor) {
		this.accessor = accessor;
	}

	public String getAccessor() {
		return this.accessor;
	}

	public boolean isCollection() {
		return isCollection;
	}
	
	public String toString() {
		return "[Attribute(name=" + this.name + ", type=" + this.type + ", accessor=" + this.accessor + "]";
	}
	
}
